using Microsoft.Win32;
using SS;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace TVSGPP.tools
{
	public class frmAppOptionFormatNumber : Form
	{
		private IContainer components = null;
		private Button btnSave;
		public GroupBox grB1;
		private TextBox txtNumFormat;
		private Label label1;
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.grB1 = new GroupBox();
			this.txtNumFormat = new TextBox();
			this.label1 = new Label();
			this.btnSave = new Button();
			this.grB1.SuspendLayout();
			base.SuspendLayout();
			this.grB1.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.grB1.Controls.Add(this.txtNumFormat);
			this.grB1.Controls.Add(this.label1);
			this.grB1.Enabled = false;
			this.grB1.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.grB1.Location = new Point(12, 7);
			this.grB1.Name = "grB1";
			this.grB1.Size = new Size(375, 374);
			this.grB1.TabIndex = 0;
			this.grB1.TabStop = false;
			this.grB1.Text = "Định dạng số sau dấu phẩy";
			this.txtNumFormat.Font = new Font("Arial", 9f);
			this.txtNumFormat.Location = new Point(180, 53);
			this.txtNumFormat.Name = "txtNumFormat";
			this.txtNumFormat.Size = new Size(70, 21);
			this.txtNumFormat.TabIndex = 1;
			this.txtNumFormat.TextAlign = HorizontalAlignment.Center;
			this.label1.AutoSize = true;
			this.label1.Font = new Font("Arial", 9f);
			this.label1.Location = new Point(30, 56);
			this.label1.Name = "label1";
			this.label1.Size = new Size(146, 15);
			this.label1.TabIndex = 0;
			this.label1.Text = "Số chữ số sau dấu phẩy :";
			this.btnSave.Cursor = Cursors.Hand;
			this.btnSave.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnSave.Location = new Point(12, 387);
			this.btnSave.Name = "btnSave";
			this.btnSave.Size = new Size(90, 30);
			this.btnSave.TabIndex = 11;
			this.btnSave.Text = "Ghi nhận";
			this.btnSave.UseVisualStyleBackColor = true;
			this.btnSave.Click += new EventHandler(this.btnSave_Click);
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.White;
			base.ClientSize = new Size(399, 427);
			base.Controls.Add(this.btnSave);
			base.Controls.Add(this.grB1);
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
			base.Name = "frmAppOptionFormatNumber";
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "Tuỳ biến giao diện";
			base.Load += new EventHandler(this.frmAppOptionMain_Load);
			this.grB1.ResumeLayout(false);
			this.grB1.PerformLayout();
			base.ResumeLayout(false);
		}
		public frmAppOptionFormatNumber()
		{
			this.InitializeComponent();
		}
		private void btnSave_Click(object sender, EventArgs e)
		{
			try
			{
				RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\TVSGPP", true);
				if (this.grB1.Enabled)
				{
					string text = "{0:0,0.";
					if (this.txtNumFormat.Text.Trim() == "")
					{
						this.txtNumFormat.Text = "0";
					}
					try
					{
						int num = int.Parse(this.txtNumFormat.Text.Trim());
						for (int i = 0; i < num; i++)
						{
							text += "0";
						}
					}
					catch
					{
					}
					text += "}";
					registryKey.SetValue("LenNumformat", text);
					Program.lenAffterDecimal = text;
				}
				registryKey.Close();
				MessageBox.Show("Dữ liệu đã được cập nhật vào hệ thống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
		private void frmAppOptionMain_Load(object sender, EventArgs e)
		{
			try
			{
				RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\TVSGPP", true);
				if (this.grB1.Enabled)
				{
					string text = registryKey.GetValue("LenNumformat").ToString().Trim();
					this.txtNumFormat.Text = (text.Substring(text.IndexOf(".") + 1, text.Length - (text.IndexOf(".") + 1)).Length - 1).ToString();
				}
				registryKey.Close();
			}
			catch
			{
			}
		}
	}
}
